class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  before_action :set_locale

  def contact_me
    @contact = Contact.language(current_language).first
  end

  def set_locale
    if params[:locale]
      session[:locale] = params[:locale]
    end

    I18n.locale = session[:locale] || I18n.default_locale
  end

  def current_language
    if I18n.locale == :"zh-CN"
      1
    elsif I18n.locale == :"en"
      2
    else
      3
    end
  end

  #def default_url_options(options={})
  #  I18n.locale = params[:locale] || I18n.default_locale
  #  { locale: I18n.locale }
  #end

end
